unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  Vcl.StdCtrls, System.Rtti, DemoAttr, FireDAC.Stan.Intf, FireDAC.Stan.Option,
  FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
  FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.MSSQL,
  FireDAC.Phys.MSSQLDef, Data.DB, FireDAC.Comp.Client, FireDAC.Stan.Param,
  FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet,
  FireDAC.VCLUI.Wait, FireDAC.Comp.UI,Class_WGFL_D7,Class_WGFL_DX,Class_WGFL_X7,
  cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore,
  dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee,
  dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
  dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
  dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
  dxSkinMcSkin, dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
  dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinPumpkin, dxSkinSeven,
  dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
  dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
  dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint,
  dxSkinXmas2008Blue, cxSSheet, cxContainer, cxEdit, cxTextEdit, cxMaskEdit,
  cxDropDownEdit, cxLookupEdit, cxDBLookupEdit, cxDBExtLookupComboBox,Class_STAF;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    FDConnection1: TFDConnection;
    FDQuery1: TFDQuery;
    Button3: TButton;
    FDGUIxWaitCursor1: TFDGUIxWaitCursor;
    Button4: TButton;
    Btnx_1: TButton;
    Btnx_2: TButton;
    Btnx_3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Btnx_1Click(Sender: TObject);
    procedure Btnx_2Click(Sender: TObject);
    procedure Btnx_3Click(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;

implementation
uses
  Class_KzUtils,Class_KzDebug;

{$R *.dfm}

procedure TForm1.Btnx_1Click(Sender: TObject);
var
  ListA:TStringlist;
  WGFLA:TWGFLX7;
begin
  FDQuery1.SQL.Clear;
  FDQuery1.SQL.Add('SELECT TOP 10000 * FROM TBL_WAGE_FL');
  FDQuery1.Open();

  KzDebug.Started;
  KzDebug.TickLog('1:X7');
  ListA:=TStringlist.Create;
  while not FDQuery1.Eof  do
  begin
    WGFLA:=TWGFLX7.ReadDS(FDQuery1);
    ListA.AddObject('',WGFLA);
    FDQuery1.Next;
  end;
  KzDebug.TickLog('2:X7');

  WGFLA:=TWGFLX7(ListA.Objects[ListA.Count-1]);
  ShowMessage(WGFLA.GetObjtIdentity);

  TKzUtils.TryFreeAndNil(ListA);
end;

procedure TForm1.Btnx_2Click(Sender: TObject);
var
  Objt:TWGFLX7;

  R: TRttiContext;
  T: TRttiType;
  F: TRttiField;
  M: TRttiMethod;
  C: TCustomAttribute;
begin
  Objt:=TWGFLX7.Create;

  R:=TRttiContext.Create;
  T:=R.GetType(Objt.ClassInfo);
  for F in T.GetFields do
  begin
    KzDebug.FileLog(F.Name);
  end;

  for M in T.GetMethods do
  begin
    KzDebug.FileLog(M.Name);
  end;

  KzDebug.FileLog(Objt.GetHashCode);
  OutputDebugString(pchar(Objt.GetObjtIdentity));
end;

procedure TForm1.Btnx_3Click(Sender: TObject);
var
  ListA:TStringlist;
  STAFA:TSTAF;
begin
  FDQuery1.SQL.Clear;
  FDQuery1.SQL.Add('SELECT  * FROM TBL_STAF');
  FDQuery1.Open();

  KzDebug.Started;
  KzDebug.TickLog('1:D7');
  ListA:=TStringlist.Create;
  while not FDQuery1.Eof  do
  begin
    STAFA:=TSTAF.ReadDS(FDQuery1);
    ListA.AddObject('',STAFA);
    FDQuery1.Next;
  end;
  KzDebug.TickLog('2:D7');

  STAFA:=TSTAF(ListA.Objects[ListA.Count-1]);
  ShowMessage(STAFA.GetObjtIdentity);

  TKzUtils.TryFreeAndNil(ListA);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  R: TRttiContext;
  T: TRttiType;
  P: TRttiProperty;
  C: TCustomAttribute;
  F: TRttiField;
  M: TRttiMethod;
begin
  try
    R := TRttiContext.Create;
    T := R.GetType(TDemoObject);
    for C in T.GetAttributes do
    begin
      if C Is MyDemoAttribute then
      begin
        showmessage(MyDemoAttribute(C).Name);
      end;
    end;

    for F in T.GetFields do
    begin
      for C in F.GetAttributes do
      begin
        if C is MyDemoAttribute then
        begin
          showmessage(MyDemoAttribute(C).Name);
        end;
      end;
    end;

    for M in T.GetMethods do
    begin
      for C in M.GetAttributes do
      begin
        if C is MyDemoAttribute then
        begin
          showmessage(MyDemoAttribute(C).Name);
        end;
      end;
    end;

  finally

  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  Demo:TDemoObject;
  R: TRttiContext;
  T: TRttiType;
  P: TRttiProperty;
  C: TCustomAttribute;
  F: TRttiField;
  M: TRttiMethod;
begin
  try
    Demo:=TDemoObject.Create;
    Demo.Field:=3;
    ShowMessageFmt('%D',[Demo.Field]);

    R:=TRttiContext.Create;
    T:=R.GetType(demo.ClassInfo);
    for F in T.GetFields do
    begin
      for C in F.GetAttributes do
      begin
        if C is MyDemoAttribute then
        begin
          //showmessage(MyDemoAttribute(C).Name);
          F.SetValue(Demo,100);
        end;
      end;
    end;

    ShowMessageFmt('%D',[Demo.Field]);
  finally
    FreeAndNil(Demo);
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  ListA:TStringlist;
  WGFLA:TWAGEFL;
begin
  FDQuery1.SQL.Clear;
  FDQuery1.SQL.Add('SELECT  * FROM TBL_WAGE_FL');
  FDQuery1.Open();

  KzDebug.Started;
  KzDebug.TickLog('1:D7');
  ListA:=TStringlist.Create;
  while not FDQuery1.Eof  do
  begin
    WGFLA:=TWAGEFL.ReadDS(FDQuery1);
    ListA.AddObject('',WGFLA);
    FDQuery1.Next;
  end;
  KzDebug.TickLog('2:D7');

  WGFLA:=TWAGEFL(ListA.Objects[ListA.Count-1]);
  ShowMessage(WGFLA.GetObjtIdentity);

  TKzUtils.TryFreeAndNil(ListA);
end;

procedure TForm1.Button4Click(Sender: TObject);
var
  ListA:TStringlist;
  WGFLA:TWAGEDX;
begin
  FDQuery1.SQL.Clear;
  FDQuery1.SQL.Add('SELECT  * FROM TBL_WAGE_FL');
  FDQuery1.Open();

  KzDebug.Started;
  KzDebug.TickLog('1:DX');
  ListA:=TStringlist.Create;
  while not FDQuery1.Eof  do
  begin
    WGFLA:=TWAGEDX.ReadDS(FDQuery1);
    ListA.AddObject('',WGFLA);
    FDQuery1.Next;
  end;
  KzDebug.TickLog('2:DX');

  WGFLA:=TWAGEDX(ListA.Objects[ListA.Count-1]);
  ShowMessage(WGFLA.GetObjtIdentity);

  TKzUtils.TryFreeAndNil(ListA);
end;

end.
